package com.wtwd.device.access;

import com.wtwd.device.entity.VerifyResult;
import com.wtwd.device.service.GatewayRedisService;
import org.springframework.http.server.reactive.ServerHttpRequest;


/**
 * @author zdl
 * @Description
 * @create 2021-08-03 19:25
 */
public abstract class AccessFactory {


    private String headerSign = "sign";
    private String headerManagerToken = "Manager-Token";
    private String headerTime = "time";


    protected String sign;
    protected String managerToken;
    protected String time;

    public AccessFactory(ServerHttpRequest request){
        this.sign =  request.getHeaders().getFirst(headerSign);
        this.managerToken =  request.getHeaders().getFirst(headerManagerToken);
        this.time=request.getHeaders().getFirst(headerTime);
    }

    /**
     * 校验请求加密是否正确
     * 加密方式采用 token+time
     * @param request
     * @param redisService
     * @return
     */
    public abstract VerifyResult verifyEncrypt(ServerHttpRequest request, GatewayRedisService redisService);
}
